package utils;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

public class DataSourceUtil {
	// TODO 可改成单例模式
	public DataSource getDataSource() {
			DataSource ds = null;
			Context ctx = null;
			try {
	            ctx = new InitialContext();
	            ds = (DataSource) ctx.lookup("java:comp/env/jdbc/ds");
	        } catch (NamingException e) {
	        	System.out.println("数据库DataSourcs出现问题，请及时处理!");
	        	e.printStackTrace();
	        }
	        return ds;
	}
}
